<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../AJAX的使用/jquery.min.js"></script>
    <script>
      var person = {
        name: "张可顺",
        age: 21,
        id: "202210731240",
        university: "江苏科技大学",
        job: function () {
          console.log("我是一个学生");
        },
        //对象的中 get set函数
        get a() {},
        set a(value) {},
      };
      //第一种调用

      console.log(person.id);
      //第二种调用
      console.log(person["age"]);
      person["userid"] = 201;
      console.log(person);
      //调用对象方法时要加括号
      person.job();
    </script>
    <!-- 需要添加是变量的属性时需要使用obj[]的方式添加 -->
    <script>
      var obj = [
        {
          name: "usename",
          value: "4",
        },
        {
          name: "password",
          value: "f",
        },
      ];
      var newObj = {};
      $.each(obj, function (index, value) {
        newObj[value.name] = value.value; //变量的添加用obj[]
        // newObj.value.name = value.value//报错
      });
      console.log(newObj);
    </script>

    <!-- 案列 -->
    <script>
      var dog = {
        name: "可可",
        type: "阿拉斯加",
        age: 5,
        color: "Red",
        skill: function () {
          console.log("bark");
          console.log("演电影");
        },
        average: function (a, b) {
          return (a + b) / 2;
        },
      };
      console.log(dog);
      dog.skill();
      var average = dog.average(1, 24);
      console.log("平均活动时间:  " + average);
    </script>

    <script>
      var arr = [1, 2, 3];
      var obj = {
        name: "zks",
        id: 2,
        arrlist: arr,
      };
    
      Object.prototype.valueOf=function(){
        return this.arrlist
      }
    //   返回对象本身
      console.log(obj.valueOf());
    </script>
  </head>

  <body></body>
</html>
